<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://xmlns.jcp.org/jsf/core">
       
        <style type="text/css">
                .ui-selectonemenu{
                    table-layout: fixed;
                    width:100% !important;
                }
                .ui-selectonemenu-label{
                    width:96% !important;
                }
                .panel .ui-selectonemenu-list { 
                    width:100% !important;
                }
                .ui-selectonemenu-filter-container {
                    width:98% !important;
                }
            </style>
    
                <h:form id="frmAddress">
                    <p:growl id="msgs" h:panelGridshowDetail="true" />

                        <p:panelGrid style="width:100%">
                            <p:row>
                                <p:column style="width: 100px">
                                    <p:outputLabel for="region" value="Регион: " />
                                </p:column>
                                <p:column>
                                    <p:selectOneMenu id="region"
                                                     value="#{mbVAddress.regionLevel}"
                                                     filter="true"  
                                                     filterMatchMode="startsWith" >
                                        <p:ajax listener="#{mbVAddress.onRegionChange}" update="county district city" />
                                        <f:selectItems value="#{mbVAddress.regions}" var="reg" 
                                                       itemLabel="#{reg.offname} #{reg.shortname}" 
                                                       itemValue="#{reg.aoguid}" />
                                    </p:selectOneMenu>  
                                </p:column>
                            </p:row>                          
                        </p:panelGrid>
                        
                        <p:panelGrid style="width: 100%;">
                                <p:row>                         
                                    <p:column style="width: 100px">
                                        <p:outputLabel for="county" value="Округ: " />
                                    </p:column>
                                    <p:column>
                                        <p:selectOneMenu id="county" 
                                                         value="#{mbVAddress.countyLevel}" 
                                                         filter="true" 
                                                         filterMatchMode="startsWith"
                                                         disabled="true">
                                            <f:selectItem itemLabel="Выбирете округ" itemValue="" noSelectionOption="true" />
                                            <f:selectItems value="#{mbVAddress.countys}" var="cou" 
                                                           itemLabel="#{cou.offname}  #{cou.shortname}" itemValue="#{cou.aoguid}"/>
                                        </p:selectOneMenu>
                                    </p:column>
                                    
                                    <p:column style="width: 100px">
                                        <p:outputLabel for="innercity" value="Внутригородской р-н: " />
                                    </p:column>
                                    <p:column>
                                        <p:selectOneMenu id="innercity" 
                                                         value="#{mbVAddress.innerCityLevel}" 
                                                         filter="true" 
                                                         filterMatchMode="startsWith">
                                            <p:ajax listener="#{mbVAddress.onInnerCityChange()}" update="street" />
                                            <f:selectItem itemLabel="Выбирете внутригородской р-н" itemValue="" noSelectionOption="true" />
                                            <f:selectItems value="#{mbVAddress.innerCitys}" var="incit" 
                                                           itemLabel="#{incit.offname} #{incit.shortname}" itemValue="#{incit.aoguid}"/>
                                        </p:selectOneMenu>
                                    </p:column>
                                </p:row>
                            
                                <p:row>
                                    <p:column style="width: 100px">
                                        <p:outputLabel for="district" value="Район: " />
                                    </p:column>
                                    <p:column>
                                        <p:selectOneMenu id="district" 
                                                         value="#{mbVAddress.districtLevel}" 
                                                         filter="true" 
                                                         filterMatchMode="startsWith">
                                            <p:ajax listener="#{mbVAddress.onDistrictChange()}" update="city innercity locality" />
                                            <f:selectItem itemLabel="Выбирете район" itemValue="" noSelectionOption="true" />
                                            <f:selectItems value="#{mbVAddress.districts}" var="dis" 
                                                           itemLabel="#{dis.offname}  #{dis.shortname}" itemValue="#{dis.aoguid}"/>
                                        </p:selectOneMenu>
                                    </p:column>
                                    <p:column style="width: 100px">
                                        <p:outputLabel for="locality" value="Населенный пункт: " />
                                    </p:column>
                                    <p:column>
                                        <p:selectOneMenu id="locality" 
                                                         value="#{mbVAddress.localityLevel}" 
                                                         filter="true" 
                                                         filterMatchMode="startsWith">
                                            <p:ajax listener="#{mbVAddress.onLocalityChange()}" update="street addGround" />
                                            <f:selectItem itemLabel="Выбирете населенный пункт" itemValue="" noSelectionOption="true" />
                                            <f:selectItems value="#{mbVAddress.localitys}" var="loc" 
                                                           itemLabel="#{loc.offname} #{loc.shortname}" itemValue="#{loc.aoguid}"/>
                                        </p:selectOneMenu>
                                    </p:column>
                                </p:row>
                            
                                <p:row>
                                    <p:column style="width: 100px">
                                        <p:outputLabel for="city" value="Город: " />
                                    </p:column>
                                    <p:column>
                                        <p:selectOneMenu id="city" 
                                                         value="#{mbVAddress.cityLevel}" 
                                                         filter="true" 
                                                         filterMatchMode="startsWith">
                                            <p:ajax listener="#{mbVAddress.onCityChange()}" update="innercity locality street" />
                                            <f:selectItem itemLabel="Выбирете город" itemValue="" noSelectionOption="true" />
                                            <f:selectItems value="#{mbVAddress.citys}" var="cit" 
                                                           itemLabel="#{cit.offname} #{cit.shortname}" itemValue="#{cit.aoguid}"/>
                                        </p:selectOneMenu>
                                    </p:column>
                                    <p:column style="width: 100px">
                                        <p:outputLabel for="street" value="Улица: " />
                                    </p:column>
                                    <p:column>
                                        <p:selectOneMenu id="street" 
                                                         value="#{mbVAddress.streetLevel}" 
                                                         filter="true" 
                                                         filterMatchMode="startsWith">
                                            <f:selectItem itemLabel="Выбирете улицу" itemValue="" noSelectionOption="true" />
                                            <f:selectItems value="#{mbVAddress.streets}" var="str" 
                                                           itemLabel="#{str.offname} #{str.shortname}" itemValue="#{str.aoguid}"/>
                                        </p:selectOneMenu>  
                                    </p:column>
                                </p:row>
                            
                                <p:row>
                                    <p:column style="width: 100px">
                                        <p:outputLabel for="addGround" value="Доп. территория: " />
                                    </p:column>
                                    <p:column>
                                        <p:selectOneMenu id="addGround" 
                                                         value="#{mbVAddress.addGroundLevel}" 
                                                         filter="true" 
                                                         filterMatchMode="startsWith">
                                            <p:ajax listener="#{mbVAddress.onAddGroundChange()}" update="streetAddGround" />
                                            <f:selectItem itemLabel="Выбирете доп. территорию" itemValue="" noSelectionOption="true" />
                                            <f:selectItems value="#{mbVAddress.addGrounds}" var="agr" 
                                                           itemLabel="#{agr.offname} #{agr.shortname}" itemValue="#{agr.aoguid}"/>
                                        </p:selectOneMenu>
                                    </p:column>
                                    <p:column style="width: 100px">
                                        <p:outputLabel for="streetAddGround" value="Улицы на доп.тер-и: " />
                                    </p:column>
                                    <p:column>
                                        <p:selectOneMenu id="streetAddGround" 
                                                         value="#{mbVAddress.streetAddGroundLevel}" 
                                                         filter="true" 
                                                         filterMatchMode="startsWith">
                                            <f:selectItem itemLabel="Выбирете улицу на доп. территории" itemValue="" noSelectionOption="true" />
                                            <f:selectItems value="#{mbVAddress.streetAddGrounds}" var="sga" 
                                                           itemLabel="#{sga.offname} #{sga.shortname}" itemValue="#{sga.aoguid}"/>
                                        </p:selectOneMenu>
                                    </p:column>
                                </p:row>
                            </p:panelGrid>


                </h:form>

        <div>
            <p:ajaxStatus style="display:block;width:16px;height:16px;
                                        position:fixed;right:50%;bottom:50%">  
                <f:facet name="start">                    
                    <h:graphicImage value="./../resources/images/loader.gif" />  
                </f:facet>  

                <f:facet name="complete">  
                    <h:outputText value="" />  
                </f:facet>  
            </p:ajaxStatus>
            <p:ajaxStatus onstart="PF('statusDialog').show()" 
                          onsuccess="PF('statusDialog').hide()" />
            <p:dialog widgetVar="statusDialog" modal="true" draggable="false" 
                      closable="false" resizable="false" showHeader="false"
                      style="opacity: 0" />
        </div>

</html>

